import { cooperationMode, cooperationType, signStatusType } from '@/views/signUp/components/status';
import { standardFormatNoHour } from '@/filters/date';
import { format } from '@/filters/date';
import { numFormat } from '@/filters/number';

export function formatValue(value, key) {
  let result = value;
  switch (key) {
    case 'cooperationMode':
    case '_cooperationMode':
      result = cooperationMode(value);
      break;
    case 'cooperationType':
    case '_cooperationType':
      result = cooperationType(value);
      break;
    case 'signStatus':
    case '_signStatus':
      result = signStatusType(value);
      break;
    case 'microtask':
    case '_microtask':
      result = value ? '是' : '否';
      break;
    case 'fansNum':
    case '_fansNum':
      result = numFormat(value, true, 1, '万');
      break;
    case 'profitSharingRatio':
    case '_profitSharingRatio':
      result = (value || value === 0) ? value + '%' : '--';
      break;
    case 'guaranteePrice':
    case '_guaranteePrice':
      result = (value || value === 0) ? value + '元' : '--';
      break;
    case 'signDate':
    case '_signDate':
      result = value ? `${format(value[0], 'YYYY/MM/DD')}-${format(value[1], 'YYYY/MM/DD')}` : '--';
      break;
    case 'lastDate':
    case '_lastDate':
    case 'effectiveDate':
    case '_effectiveDate':
      result = value ? standardFormatNoHour(value / 1000) : '--';
      break;
  }
  if (!result && result !== 0) {
    return '--';
  }
  return result;
}
